package alijk.dataView.controller;

import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import flexjson.JSONSerializer;
import alijk.dataView.service.SysUserInf;

@Controller
@Scope(value = "prototype")
@RequestMapping("/mybatis/")
public class MyBatisQueryTest {
	
	@Autowired
	private SysUserInf sysUserInf;
	
	@RequestMapping("userList.do")
	@ResponseBody
	public String getUserList() {
		String list = "";
		Map<String, Object> map_query = new HashMap<String, Object>();
		map_query.put("data_flag", "0");
		try {
			List<Map<String, Object>> map = sysUserInf.getAlluser(map_query);
			for(Map<String, Object> user : map){
				Iterator<String> iter = user.keySet().iterator();
				String row = "";
				while(iter.hasNext()){
					row += user.get(iter.next())+"\t";
				}
				System.out.println(row);
			}
			list = new JSONSerializer().deepSerialize(map);
		} catch (Exception e) {
			e.getStackTrace();
		}
		return list;
	}
}
